﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Tiquete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["CadenaDeConexion"] = ConfigurationManager.ConnectionStrings["SIG"].ConnectionString;
        ((Label)FormViewTiquete.FindControl("LabelFechaCompra")).Text = DateTime.Now.ToShortDateString();
        //((Label)FormViewTiquete.FindControl("LabelCalcular")).Attributes.Add("onClick", string.Concat("CalcularValorCompra('", ((TextBox)FormViewTiquete.FindControl("ValorTiqueteTextBox")).ClientID, "','", ((TextBox)FormViewTiquete.FindControl("CantidadTiquetesTextBox")).ClientID, "');)"));
        ((Label)FormViewTiquete.FindControl("LabelCalcular")).Attributes.Add("onClick", string.Concat("document.getElementById('", ((Label)FormViewTiquete.FindControl("LabelValorCompra")).ClientID, "').innerHTML = document.getElementById('", ((TextBox)FormViewTiquete.FindControl("ValorTiqueteTextBox")).ClientID, "').value * document.getElementById('", ((TextBox)FormViewTiquete.FindControl("CantidadTiquetesTextBox")).ClientID, "').value"));
    }
    
    protected void LinkButtonAddNew_Click(object sender, EventArgs e)
    {
        FormViewTiquete.ChangeMode(FormViewMode.Insert);
        FormViewTiquete.Visible = true;
    }
    
    protected void FormViewTiquete_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        limpiarFormulario();
    }

    protected void InsertCancelButton_Click(object sender, EventArgs e)
    {
        limpiarFormulario();
    }

    private void limpiarFormulario()
    {
        FormViewTiquete.Controls.Clear();
        FormViewTiquete.Visible = false;
    }
    protected void DropDownListIdentificadorUsuario_SelectedIndexChanged(object sender, EventArgs e)
    {
        ((HiddenField)FormViewTiquete.FindControl("HiddenFieldIdentificadorUsuario")).Value = ((DropDownList)sender).SelectedValue;
    }
    protected void ObjectDataSourceUsuariosPorDocumento_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        e.InputParameters["numeroDeDocumento"] = ((TextBox)FormViewTiquete.FindControl("txtNumeroDeDocumento")).Text;
    }
}
